use Table3.dta,clear
global control2_nomountain dist_town2002 minority incpc98 vpop2002  disaster2002 
 
**first stage***
reg  direct_election2002 secretary_year   mountain_new perc_fivesurnmae age age_sq male  ///
ethnic  mood i.province, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=direct_election2002) replace

**first stage***
reg nomination2002 secretary_year   mountain_new perc_fivesurnmae   age age_sq male  ///
ethnic  mood i.province,vce(boot)
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=nomination2002) append

**second stage column1**
ivreg2 happy (direct_election2002 nomination2002= secretary_year mountain_new perc_fivesurnmae) age age_sq male ///
ethnic  mood i.province, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(second: y=happy) append

boottest  nomination2002 , seed(1000) reps(999) nograph
  mat B[2,1]=r(p)
  mat B[2,2]=r(z) 

****column2*****
reg direct_election2002 secretary_year   mountain_new perc_fivesurnmae  age age_sq male married  ///
ethnic ccp cadre_now cadre_past edu_year  health mood l_houincpc ///
net_wealth working_hour unemployed  i.province, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=direct_election2002) append

reg nomination2002 secretary_year   mountain_new perc_fivesurnmae  age age_sq male married  ///
ethnic ccp cadre_now cadre_past edu_year  health mood l_houincpc ///
net_wealth working_hour unemployed  i.province, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=nomination2002) append

***second stage column2***
ivreg2 happy  (direct_election2002 nomination2002= secretary_year   mountain_new perc_fivesurnmae)  age age_sq male married  ///
ethnic ccp cadre_now cadre_past edu_year  health mood l_houincpc ///
net_wealth working_hour unemployed  i.province, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(second: y=happy) append

boottest  nomination2002 , seed(1000) reps(999) nograph
  mat B[2,1]=r(p)
  mat B[2,2]=r(z) 
  
  
//the following specifications restrict the obs to respondents who are heads of household or heads' spouses 

****column3****
reg direct_election2002 secretary_year   mountain_new perc_fivesurnmae  age age_sq male ///
ethnic ccp cadre_now cadre_past edu_year child health mood l_houincpc ///
net_wealth working_hour unemployed  ccp_s cadre_now_s cadre_past_s sp_edu_new ///
health_s unemployed_s   i.province if H2_101<=2, cluster(Village_code)  
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=direct_election2002) append

reg nomination2002 secretary_year   mountain_new perc_fivesurnmae  age age_sq male  ///
ethnic ccp cadre_now cadre_past edu_year child health mood l_houincpc ///
net_wealth working_hour unemployed  ccp_s cadre_now_s cadre_past_s sp_edu_new ///
health_s unemployed_s   i.province if H2_101<=2, cluster(Village_code) 
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=nomination2002) append

***second stage column3***
ivreg2 happy  (direct_election2002 nomination2002= secretary_year   mountain_new perc_fivesurnmae)  age age_sq male  ///
ethnic ccp cadre_now cadre_past edu_year child  health mood l_houincpc ///
net_wealth working_hour unemployed  ccp_s cadre_now_s cadre_past_s sp_edu_new ///
health_s unemployed_s   i.province if H2_101<=2, cluster(Village_code)  
outreg2 using ivreg2-first, excel dec(4) ctitle(second: y=happy) append

boottest  nomination2002 , seed(1000) reps(999) nograph
  mat B[2,1]=r(p)
  mat B[2,2]=r(z) 
  
****column 4****
reg direct_election2002 secretary_year   mountain_new perc_fivesurnmae dist_town2002 minority incpc98 vpop2002  disaster2002  age age_sq male  ///
ethnic ccp cadre_now cadre_past edu_year child health mood l_houincpc ///
net_wealth working_hour unemployed  ccp_s cadre_now_s cadre_past_s sp_edu_new ///
health_s unemployed_s muchabove_aveinc above_aveinc muchbelow_aveinc below_aveinc ///
better_living worse_living expbig_increase expsmall_increase exp_decrease ///
 i.province if H2_101<=2, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=direct_election2002) append

reg nomination2002 secretary_year   mountain_new perc_fivesurnmae dist_town2002 minority incpc98 vpop2002  disaster2002 age age_sq male   ///
ethnic ccp cadre_now cadre_past edu_year child health mood l_houincpc ///
net_wealth working_hour unemployed  ccp_s cadre_now_s cadre_past_s sp_edu_new ///
health_s unemployed_s muchabove_aveinc above_aveinc muchbelow_aveinc below_aveinc ///
better_living worse_living expbig_increase expsmall_increase exp_decrease ///
 i.province if H2_101<=2, cluster(Village_code)
outreg2 using ivreg2-first, excel dec(4) ctitle(first: y=nomination2002) append

ivreg2 happy  (direct_election2002 nomination2002= secretary_year   mountain_new perc_fivesurnmae)  dist_town2002 minority incpc98 vpop2002  disaster2002  age age_sq male   ///
ethnic ccp cadre_now cadre_past edu_year child health mood l_houincpc ///
net_wealth working_hour unemployed  ccp_s cadre_now_s cadre_past_s sp_edu_new ///
health_s unemployed_s muchabove_aveinc above_aveinc muchbelow_aveinc below_aveinc ///
better_living worse_living expbig_increase expsmall_increase exp_decrease ///
 i.province if H2_101<=2, cluster(Village_code)  
outreg2 using ivreg2-first, excel dec(4) ctitle(second: y=happy) append

boottest  nomination2002 , seed(1000) reps(999) nograph
  mat B[2,1]=r(p)
  mat B[2,2]=r(z) 
